<template>
	<view class="product-card">
		<image :src="post.funplay_urls[0]" class="product-image" mode="aspectFill" />
		<view class="product-info">
			<text class="product-title">{{ post.funplay_title }}</text>
			<view class="product-footer">
				<view class="likes">
					<image src="/static/images/xin.png" class="like-icon"></image>
					<!-- <view @click="clickLike()">
						<image v-if="isLike" src="/static/images/xinxin.png" class="like-icon"></image>
						<image v-else src="/static/images/xinxin2.png" class="like-icon"></image>
					</view> -->
					<text class="like-count">{{ post.likes }}</text>
				</view>
				<text class="store-name">{{ post.user_name }}</text>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { ref, watch } from 'vue'
	import { SearchPost } from '@/types/types'
	import { useCommonStore } from '../stores/useCommonStore';

	const props = defineProps<{
		post : SearchPost
	}>();
	const emit = defineEmits(['update:post'])
	
	const isLike = ref(false)
	function clickLike() {
		isLike.value = !isLike.value
	}
</script>

<style scoped lang="scss">
	.product-card {
		/* width: calc(50% - 0.5rem);
		/ margin: 0.25rem;*/
		width: 100%;
		border-radius: 0.75rem;
		background: #fff;
		overflow: hidden;
		box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
	}

	.product-image {
		width: 85%;
		height: 8rem;
		object-fit: cover;
		margin: 0.8rem 0.8rem 0 0.8rem;
		border-radius: 0.63rem;
	}

	.product-info {
		width: 100%;
		box-sizing: border-box;
		padding: 0.5rem;
	}

	.product-title {
		font-size: 0.875rem;
		color: #333;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		line-height: 1.2rem;
		margin-bottom: 0.5rem;
		height: 2.4rem;
	}

	.product-footer {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 0.75rem;
	}

	.likes {
		display: flex;
		align-items: center;
		gap: 0.25rem;
		.like-icon {
			width: 40rpx;
			height: 40rpx;
		}
		.like-count {
			color: #666;
			margin-top: 0rem;
		}
	}
	.store-name {
		width: 61%;
		color: #666;
		margin-top: 0rem;
		/*font-weight: 600;*/
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap; /* 简化为单行截断 */
		text-align: right;
	}
</style>